package com.netease.commenta;

import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;

import com.netease.commenta.model.Commodity;
import com.netease.commenta.widget.FixedListView;
import com.netease.commenta.widget.CommodityAdapter;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window window = getWindow();
            window.setFlags(
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
                    WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.activity_main);
        FixedListView shuffleList = (FixedListView) findViewById(R.id.shuffle_list);
        shuffleList.setAdapter(new CommodityAdapter(this, R.layout.item_shuffle, getData()));
        findViewById(R.id.btn_reload_shuffle).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                findViewById(R.id.ico_reload_shuffle).startAnimation(
                        AnimationUtils.loadAnimation(MainActivity.this, R.anim.round));
            }
        });
    }

    private List<Commodity> getData() {
        List<Commodity> data = new ArrayList<>();
        data.add(new Commodity("测试商品1"));
        data.add(new Commodity("测试商品2"));
        data.add(new Commodity("很长很长很长很长很长的测试商品3啦啦啦很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长哈哈啦啦啦测试3"));
        return data;
    }
}
